package dao;

import org.apache.ibatis.session.SqlSession;

import mapper.CustomerMapper;
import model.Customer;
import utils.MyBatisUtils;

public class CustomerDao {
	public Customer find(String id) {
		SqlSession session=MyBatisUtils.getSqlSession();
		CustomerMapper mapper=session.getMapper(CustomerMapper.class);
		Customer obj=mapper.find(id);
		session.close();
		return obj;
	}
	public void insert(Customer obj) {
		SqlSession session=MyBatisUtils.getSqlSessionAutoCommit();
		CustomerMapper mapper=session.getMapper(CustomerMapper.class);
		mapper.insert(obj);
		session.close();
	}
	
	public void update(Customer obj) {
		SqlSession session=MyBatisUtils.getSqlSessionAutoCommit();
		CustomerMapper mapper=session.getMapper(CustomerMapper.class);
		mapper.update(obj);
		session.close();
	}
	
	public void delete(String id) {
		SqlSession session=MyBatisUtils.getSqlSessionAutoCommit();
		CustomerMapper mapper=session.getMapper(CustomerMapper.class);
		mapper.delete(id);
		session.close();
	}

}
